<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="java.util.*" %>
<%@ include file="/page/taglibs.jsp" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<%@ include file="/adapter/adapter-bootstrap.jsp" %>
</head>
<script type="text/javascript">

function save(){
	var str_data=$("#baseinfo input").map(function(){
		   return ($(this).attr("name")+'='+$(this).val());
		 }).get().join("&") ;
    $.ajax({
        url:"${ctx}/pagemgr/savePage",
        type: "POST",      
        dataType:"json",
        data: str_data,
        async: false,
        success: function(data) {
        	if(data.flag>0){
	            alert("保存成功！");	
	            //window.location.reload();
        	}
/* 	          $.each(data, function(index, element) {
             window.location.reload();
          }); */
        },
        error: function() {
          alert("error");
        }
      });
	
}

function  goBack(){
	//window.location.href='${ctx}/appFrameModule1/appFrameTradeMain?appid=${appid}'
	window.history.back(-1);
	//window.history.go(-2);
}

function  changeValue1(page_make_mode){
	   document.getElementById("pageMakeMode").value=page_make_mode;	
}

function  changeValue2(template_id){
	   document.getElementById("templateId").value=template_id;	
	  // changeImg (template_id);//动态改变图片
}
function changeImg (templateid) { 
    document.getElementById('imgId').src = '${ctx}/sysws/template/' + templateid + '.png';
}
</script>
<body>
<div class="panel panel-default ">
   <div class="panel-heading">
      <h3 class="panel-title">
          创建页面
      </h3>
   </div>
   <div class="panel-body">
<form class="form-horizontal" role="form" id="baseinfo" name="baseinfo"  action="${pageContext.request.contextPath }/appBaseInfo/addAppBaseInfo" method="post">

                       <div class="form-group">
                       	  <input class="input-sm form-control" id="moduleId" name="moduleId" type="hidden" value="${moduleid }"/>
                          <label class="col-xs-2 control-label" for="pageId">页面标识</label>
                          <div class="col-xs-9">
                             <input class="input-sm form-control" id="pageId" name="pageId" type="text" placeholder="页面唯一编号"  onBlur="vailId()"/> 
                          </div>
                       </div>
                       <div class="form-group">
                          <label class="col-xs-2 control-label" for="pageName">页面名称</label>
                          <div class="col-xs-9">
                             <input class="input-sm form-control" placeholder="给页面起个名字"  id="pageName" name="pageName" type="text" />
                          </div>
                       </div>
                       <div class="form-group">
                          <input type="hidden"  id="pageMakeMode" name="pageMakeMode" type="text" value='1'/>
                          <label class="col-xs-2 control-label" for="ds_name">页面制作方式</label>
                          <div class="col-xs-9">
								<select id="page_make_mode" class="form-control"  onclick="changeValue1(this.value)">
								  <option  value='1' selected="selected">模板配置生成</option>
								  <option  value='2'>自定义页面</option>
								</select>                             
                          </div>
                       </div>                       
                          <div class="form-group">
                          <input type="hidden"  id="templateId" name="templateId" type="text" value='${spbList[0].TEMPLATE_ID}'/>
                          <label class="col-xs-2 control-label" for="ds_username">选择模板</label>
                          <!-- <input type="hidden"  id="templateId" name="templateId" type="text" /> -->
                          <div class="col-xs-9">
                          	    <select id="template_id" class="form-control"  onclick="changeValue2(this.value)">
								<c:forEach items="${spbList}" var="page" varStatus="s" >
								  <option value="${page.TEMPLATE_ID}">${page.TEMPLATE_NAME}</option>
<!-- 								  <option>标准修改页面模板</option>
								  <option>标准列表页面模板</option>
								  <option>标准查看页面模板</option>	 -->	
								</c:forEach>						  
								</select>                             
                          </div>
                       </div>
					  <div class="form-group">
					    <label class="col-xs-2 control-label"></label>
					    <div class="col-xs-9">
					      <p class="form-control-static">显示所选模板图片</p>
					    </div>
					  </div>
                       <div class="form-group">
                       		<div class="col-xs-3"></div>
                       		<div class="col-xs-5"><img src="/macms/images/demo.jpg" width="375" height="667" class="img-thumbnail"></div>
                       		<%-- <img src="${ctx}/sysws/template/${templateId}.png"  id="imgId" class="img-responsive"></img> --%>
                       </div>
                    <br></br>                       
                    <br></br>

					<div class="form-group">
						<div class="col-xs-5"></div>
						<div class="col-xs-5">
							<button type="button" class="btn btn-default" onclick="save()">&nbsp;&nbsp;确定&nbsp;&nbsp;</button>
							<button type="button" class="btn btn-default"  onclick="history.go(-1)">&nbsp;&nbsp;返回&nbsp;&nbsp;</button>
						</div>
					</div>
                    <br></br>
                </form>
	</div>
	</div>
</body>
</html>
